public class LogIn {
    private String userName = "admin";
    private String password = "123455";
    private static void loginInfo (String userName, String password) throws UserNameException,PasswordException{
        if (!userName.equals(userName)) {
            //此时用户名输入错误，就需要报异常
            //此时抛出自定义异常
            throw new UserNameException("用户名有问题");
        }
        if (!password.equals((password))) {
            //此时密码错误
            throw new PasswordException("密码有问题");
        }
        System.out.println("登陆成功");
    }

    public static void main(String[] args) {
        //此时通过throws已经声明了异常
        //调用方法里面需要通过 try-catch 来解决
        try {
            loginInfo("admin","123456");
        } catch (UserNameException e) {

        } catch (PasswordException e) {

        } finally {

        }
        String s1 = new String("hello");
        String s2 = new String("world");
        String s3 = s1;
        s1.equals(s2);
        String ss1 = "abcabcabc";
        int index = ss1.lastIndexOf("ab",3);//给定位置开始找 目前从下标 3 开始往后找
        System.out.println(index);//3

    }
}

//extends Exception          编译时异常
//extends RuntinmeException  运行时异常

class UserNameException extends Exception {
    //自定义异常一定要继承于异常
    //此时为编译时异常
    public UserNameException (String message) {
        super(message);
    }
}

class PasswordException extends Exception {
    public PasswordException (String message) {
        super(message);
    }
}